package com.ehotting.edsta.diagnosisPredict.controller;

import com.ehotting.eaf.core.domain.R;
import com.ehotting.edsta.diagnosisPredict.domain.dto.TrainingInfoDto;
import com.ehotting.edsta.diagnosisPredict.feign.TraininginfoFeignService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 模型任务训练
 */
@Api(tags = "TraininginfoController",description = "模型任务训练")
@RestController
@RequestMapping("traininginfo")
public class TraininginfoController {

    @Autowired
    private TraininginfoFeignService traininginfoFeignService;

    /**
     * 创建保存模型信息
     * @param dto
     * @return
     */
    @ApiOperation(value = "创建保存模型信息",notes = "返回的数据类型：TrainingInfoDto")
    @PostMapping(value = "/training-info/create")
    public R<TrainingInfoDto> trainingInfoCreate(@RequestBody TrainingInfoDto dto){
        return R.convert(traininginfoFeignService.trainingInfoCreate(dto));
    }

    /**
     * 模型任务启动
     * @param id
     * @return
     */
    @ApiOperation(value = "模型任务启动",notes = "")
    @PostMapping(value = "/training-info/{id}/startTask")
    public R<Boolean> startTask(@PathVariable("id") Long id){
        return R.convert(traininginfoFeignService.startTask(id));
    }

    /**
     * 点击发布
     * @param projectId
     * @return
     */
    @ApiOperation(value = "点击发布",notes = "返回的数据类型：TrainingInfoDto")
    @GetMapping(value = "/training-info/getByProjectId")
    public R<TrainingInfoDto> getByProjectId(@RequestParam("projectId") Long projectId){
        return R.convert(traininginfoFeignService.getByProjectId(projectId));
    }

}